package com.util;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Util {
	public static final ByteBuffer getUTFByteBuffer(String message) {
		CharsetEncoder encoder = Charset.forName("utf-8").newEncoder();
		ByteBuffer bb = null;
		try {
			bb = encoder.encode(CharBuffer.wrap(message));
		} catch (CharacterCodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return bb;
	}

	public static final String getNowDatetime() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		String datetime = sdf.format(new Date());
		return datetime;
	}
}
